home *** CD-ROM | disk | FTP | other *** search
/ Champak 106 / Vol 106.iso / games / insuranc.swf / scripts / __Packages / Game.as < prev    next >
Encoding:
Text File  |  2010-04-12  |  21.1 KB  |  682 lines

  1. class Game extends MovieClip
  2. {
  3.    var mcSummary;
  4.    var lives;
  5.    var points;
  6.    var mcLevel;
  7.    var mcStatusBar;
  8.    var mcPoints;
  9.    var mcEnergy;
  10.    var mcLives;
  11.    var btnPause;
  12.    var aRoadTiles;
  13.    var aRoadDef;
  14.    var aRandomCarsDef;
  15.    var aEnemiesDef;
  16.    var mcBonus;
  17.    var bmpRoad;
  18.    var bmpShoulder;
  19.    var mcCanvas;
  20.    var aRoad;
  21.    var aRoadBmp;
  22.    var aRoadNames;
  23.    var aRoadShoulderBmp;
  24.    var aRoadShoulderNames;
  25.    var roadInd;
  26.    var lane;
  27.    var distance;
  28.    var totalDistance;
  29.    var sEnemy;
  30.    var enemy;
  31.    var player;
  32.    var aRandomCars;
  33.    var onEnterFrame;
  34.    var mcObstacle;
  35.    var puddle;
  36.    var mcShot;
  37.    var mcContinue;
  38.    var mcMissionInfo;
  39.    var counter;
  40.    var startTime;
  41.    var oKeyList;
  42.    static var instance;
  43.    static var carDepth;
  44.    static var bulletDepth;
  45.    static var level = 0;
  46.    static var screenW = 550;
  47.    static var screenH = 400;
  48.    function Game(Void)
  49.    {
  50.       super();
  51.       Game.instance = this;
  52.       this.mcSummary.gotoAndStop(1);
  53.       this.lives = !Application.bEasy ? 3 : 4;
  54.       Game.level = 0;
  55.       this.points = 0;
  56.       this.mcLevel = this.mcStatusBar.mcLevel;
  57.       this.mcPoints = this.mcStatusBar.mcPoints;
  58.       this.mcEnergy = this.mcStatusBar.mcEnergy;
  59.       this.mcLives = this.mcStatusBar.mcLives;
  60.       this.btnPause = this.mcStatusBar.btnPause;
  61.       this.btnPause.onRelease = mx.utils.Delegate.create(this,this.onReleasePause);
  62.       this.mcStatusBar.btnEasyMoney.onRelease = function()
  63.       {
  64.          this.getURL("http://www.easymoney.com","_blank");
  65.       };
  66.       this.aRoadTiles = new Array();
  67.       this.aRoadTiles[0] = {ind:0,sName:"road 0",width:550,height:400,b2Lanes:false};
  68.       this.aRoadTiles[1] = {ind:1,sName:"road 1",width:550,height:400,b2Lanes:false};
  69.       this.aRoadTiles[2] = {ind:2,sName:"road 2",width:550,height:400,b2Lanes:false};
  70.       this.aRoadTiles[3] = {ind:3,sName:"road 3",width:550,height:400,b2Lanes:false};
  71.       this.aRoadTiles[4] = {ind:4,sName:"road 4",width:550,height:400,b2Lanes:false};
  72.       this.aRoadTiles[5] = {ind:5,sName:"road 5",width:550,height:400,b2Lanes:true};
  73.       this.aRoadTiles[6] = {ind:6,sName:"road 6",width:550,height:200,b2Lanes:true};
  74.       this.aRoadTiles[7] = {ind:7,sName:"road 7",width:550,height:400,b2Lanes:true};
  75.       this.aRoadTiles[8] = {ind:8,sName:"road 8",width:550,height:200,b2Lanes:true};
  76.       this.aRoadTiles[9] = {ind:9,sName:"road 9",width:550,height:400,b2Lanes:false};
  77.       this.aRoadTiles[10] = {ind:10,sName:"road 10",width:550,height:400,b2Lanes:false};
  78.       this.aRoadTiles[11] = {ind:11,sName:"road 11",width:550,height:400,b2Lanes:false};
  79.       this.aRoadTiles[12] = {ind:12,sName:"road 12",width:550,height:400,b2Lanes:false};
  80.       this.aRoadTiles[13] = {ind:13,sName:"road 13",width:550,height:400,b2Lanes:false};
  81.       this.aRoadTiles[14] = {ind:14,sName:"road 14",width:550,height:400,b2Lanes:false};
  82.       this.aRoadTiles[15] = {ind:15,sName:"road 15",width:550,height:400,b2Lanes:false};
  83.       this.aRoadTiles[16] = {ind:16,sName:"road 16",width:550,height:400,b2Lanes:false};
  84.       this.aRoadDef = new Array();
  85.       this.aRoadDef[0] = new Array(0,0,0,0,1,2,2,2,3,4,5,5,6,7,7,7,8,9,2,2,2,3,0,0,0,11,13,13,13,15,0,0,4,5,5,6,7,7,8,5,5,9,2,2,3,0,12,14,14,14,16);
  86.       this.aRandomCarsDef = new Array();
  87.       this.aRandomCarsDef[0] = {sLinkageId:"car1",maxVel:25,minVel:5};
  88.       this.aRandomCarsDef[1] = {sLinkageId:"car2",maxVel:25,minVel:5};
  89.       this.aRandomCarsDef[2] = {sLinkageId:"car3",maxVel:25,minVel:5};
  90.       this.aRandomCarsDef[3] = {sLinkageId:"car4",maxVel:25,minVel:5};
  91.       this.aRandomCarsDef[4] = {sLinkageId:"car5",maxVel:25,minVel:5};
  92.       this.aRandomCarsDef[5] = {sLinkageId:"car6",maxVel:25,minVel:5};
  93.       this.aRandomCarsDef[6] = {sLinkageId:"car7",maxVel:25,minVel:5};
  94.       this.aEnemiesDef = new Array();
  95.       this.aEnemiesDef.push("esure");
  96.       this.aEnemiesDef.push("tesco");
  97.       this.aEnemiesDef.push("directLine");
  98.       this.aEnemiesDef.push("elephant");
  99.       this.aEnemiesDef.push("sainsbury");
  100.       this.aEnemiesDef.push("rac");
  101.       this.aEnemiesDef.push("churchil");
  102.       this.aEnemiesDef.push("moreThan");
  103.       this.aEnemiesDef.push("asda");
  104.       this.aEnemiesDef.push("lloyd");
  105.       this.aEnemiesDef.push("aa");
  106.       this.aEnemiesDef.push("admiral");
  107.       this.showMissionInfo();
  108.       Sounds.stopAllSounds();
  109.       Sounds.playSound("water",99999);
  110.       Sounds.setVolume("water",18);
  111.       Sounds.startAmbience(true);
  112.       this.setPointsMeter();
  113.       this.setLevelMeter();
  114.       this.setLivesMeter();
  115.       this.setEnergyMeter(100);
  116.    }
  117.    static function getInstance(Void)
  118.    {
  119.       return Game.instance;
  120.    }
  121.    function initLevel(Void)
  122.    {
  123.       trace("Application.bEasy> " + Application.bEasy);
  124.       this.btnPause.enabled = true;
  125.       this.mcBonus.gotoAndStop(1);
  126.       Game.carDepth = 10;
  127.       Game.bulletDepth = 100;
  128.       this.bmpRoad = new flash.display.BitmapData(Game.screenW,Game.screenH,false);
  129.       this.bmpShoulder = new flash.display.BitmapData(Game.screenW,Game.screenH,true,0);
  130.       this.mcCanvas.attachBitmap(this.bmpShoulder,0);
  131.       this.mcCanvas.attachBitmap(this.bmpRoad,1,"Never");
  132.       this.aRoad = new Array();
  133.       var _loc4_ = this.aRoadDef[0].length;
  134.       var _loc2_ = 0;
  135.       while(_loc2_ < _loc4_)
  136.       {
  137.          this.aRoad[_loc2_] = this.aRoadTiles[this.aRoadDef[0][_loc2_]];
  138.          _loc2_ = _loc2_ + 1;
  139.       }
  140.       this.aRoadBmp = new Array();
  141.       this.aRoadNames = new Array();
  142.       this.aRoadShoulderBmp = new Array();
  143.       this.aRoadShoulderNames = new Array();
  144.       this.roadInd = 0;
  145.       this.lane = 0;
  146.       this.distance = 0;
  147.       this.totalDistance = 0;
  148.       this.draw();
  149.       this.sEnemy = this.aEnemiesDef[Game.level];
  150.       if(Application.bEasy)
  151.       {
  152.          this.enemy = new Enemy(8000 + 500 * Game.level,this.sEnemy,new flash.geom.Point(275,Game.screenH + 80),new flash.geom.Point(0,0),this.mcCanvas,900);
  153.       }
  154.       else
  155.       {
  156.          this.enemy = new Enemy(15000 + 1000 * Game.level,this.sEnemy,new flash.geom.Point(275,Game.screenH + 80),new flash.geom.Point(0,0),this.mcCanvas,900);
  157.       }
  158.       this.player = new PlayerCar(new flash.geom.Point(300,-50),this.mcCanvas,this.sEnemy);
  159.       var _loc3_ = undefined;
  160.       if(Application.bEasy)
  161.       {
  162.          _loc3_ = Game.level >= 5 ? 2 : 1;
  163.       }
  164.       else
  165.       {
  166.          _loc3_ = 2;
  167.       }
  168.       this.aRandomCars = new Array();
  169.       _loc2_ = 0;
  170.       while(_loc2_ < _loc3_)
  171.       {
  172.          this.addRandomCar(220 + _loc2_ * 60);
  173.          _loc2_ = _loc2_ + 1;
  174.       }
  175.       this.addPuddle(new flash.geom.Point(-50,-55));
  176.       this.setPointsMeter();
  177.       this.setLevelMeter();
  178.       this.setLivesMeter();
  179.       this.setEnergyMeter(100);
  180.    }
  181.    function startWork(Void)
  182.    {
  183.       this.onEnterFrame = this.loop;
  184.       Sounds.stopSound("engineIdle");
  185.       Sounds.playSound("engineIdle",99999);
  186.    }
  187.    function stopWork(Void)
  188.    {
  189.       Sounds.stopSound("engineIdle");
  190.       this.onEnterFrame = null;
  191.    }
  192.    function step(Void)
  193.    {
  194.       this.player.step();
  195.       var _loc7_ = this.bmpShoulder.hitTest(new flash.geom.Point(0,0),250,new flash.geom.Point(this.player.pos.x,Game.screenH - this.player.pos.y));
  196.       if(_loc7_)
  197.       {
  198.          this.player.reactionOnShoulder(this.bmpShoulder);
  199.       }
  200.       this.player.checkObstacle(this.mcObstacle);
  201.       this.player.checkPuddle(this.puddle);
  202.       this.enemy.step(this.player,this.totalDistance,this.bmpShoulder);
  203.       if(this.enemy.bOnScreen)
  204.       {
  205.          this.enemy.checkDistance(this.player);
  206.          this.enemy.checkCollision(this.player,true);
  207.          this.enemy.checkWeapon(this.player.mcWeaponArea);
  208.       }
  209.       var _loc4_ = this.aRandomCars.length;
  210.       var _loc2_ = 0;
  211.       while(_loc2_ < _loc4_)
  212.       {
  213.          this.aRandomCars[_loc2_].step(this.player.pos,this.player.vel,this.bmpShoulder);
  214.          this.aRandomCars[_loc2_].checkDistance(this.player);
  215.          this.aRandomCars[_loc2_].checkCollision(this.player,true);
  216.          if(this.enemy.bOnScreen)
  217.          {
  218.             this.aRandomCars[_loc2_].checkDistance(this.enemy);
  219.             this.aRandomCars[_loc2_].checkCollision(this.enemy,false);
  220.          }
  221.          this.aRandomCars[_loc2_].checkWeapon(this.player.mcWeaponArea);
  222.          var _loc3_ = _loc2_ + 1;
  223.          while(_loc3_ < _loc4_)
  224.          {
  225.             this.aRandomCars[_loc2_].checkDistance(this.aRandomCars[_loc3_]);
  226.             this.aRandomCars[_loc2_].checkCollision(this.aRandomCars[_loc3_],false);
  227.             _loc3_ = _loc3_ + 1;
  228.          }
  229.          _loc2_ = _loc2_ + 1;
  230.       }
  231.       if(this.mcShot)
  232.       {
  233.          this.mcShot.step(this.player.vel);
  234.       }
  235.       if(this.mcObstacle)
  236.       {
  237.          this.mcObstacle.step(this.player.vel);
  238.       }
  239.       var _loc6_ = "";
  240.       var _loc5_ = this.aRoad[this.roadInd];
  241.       this.totalDistance += this.player.vel.y;
  242.       this.distance += this.player.vel.y;
  243.       if(this.distance > _loc5_.height)
  244.       {
  245.          this.roadInd = this.roadInd + 1;
  246.          if(this.roadInd == this.aRoad.length)
  247.          {
  248.             this.roadInd = 0;
  249.          }
  250.          this.distance -= _loc5_.height;
  251.          _loc6_ = _loc5_.sName;
  252.       }
  253.       if(_loc5_.b2Lanes && this.player.pos.x > Game.screenW / 2)
  254.       {
  255.          this.lane = 1;
  256.       }
  257.       else
  258.       {
  259.          this.lane = 0;
  260.       }
  261.       this.setRoadBmp(_loc6_);
  262.       this.puddle.step(this.player.vel);
  263.    }
  264.    function draw(Void)
  265.    {
  266.       this.player.draw();
  267.       this.enemy.draw();
  268.       var _loc13_ = this.aRandomCars.length;
  269.       var _loc2_ = 0;
  270.       while(_loc2_ < _loc13_)
  271.       {
  272.          this.aRandomCars[_loc2_].draw();
  273.          _loc2_ = _loc2_ + 1;
  274.       }
  275.       if(this.mcShot)
  276.       {
  277.          this.mcShot.draw();
  278.       }
  279.       if(this.mcObstacle)
  280.       {
  281.          this.mcObstacle.draw();
  282.       }
  283.       _loc13_ = this.aRandomCars.length;
  284.       _loc2_ = 0;
  285.       while(_loc2_ < _loc13_)
  286.       {
  287.          this.aRandomCars[_loc2_].step(this.player.pos,this.player.vel,this.bmpShoulder);
  288.          _loc2_ = _loc2_ + 1;
  289.       }
  290.       this.bmpShoulder.fillRect(this.bmpShoulder.rectangle,0);
  291.       var _loc3_ = - this.distance;
  292.       var _loc6_ = this.roadInd;
  293.       _loc13_ = this.aRoadBmp.length;
  294.       _loc2_ = 0;
  295.       while(_loc2_ < _loc13_)
  296.       {
  297.          var _loc4_ = this.aRoad[_loc6_];
  298.          var _loc9_ = this.aRoadBmp[_loc2_];
  299.          var _loc11_ = this.aRoadShoulderBmp[_loc2_];
  300.          var _loc5_ = 0;
  301.          _loc3_ += _loc4_.height - 1;
  302.          if(_loc3_ > Game.screenH)
  303.          {
  304.             _loc5_ = _loc3_ - Game.screenH;
  305.             _loc3_ = Game.screenH;
  306.          }
  307.          var _loc10_ = _loc5_;
  308.          var _loc12_ = _loc4_.height - 1 - _loc5_;
  309.          var _loc7_ = new flash.geom.Rectangle(0,_loc10_,_loc4_.width,_loc12_);
  310.          var _loc8_ = new flash.geom.Point(0,Game.screenH - _loc3_);
  311.          this.bmpRoad.copyPixels(_loc9_,_loc7_,_loc8_,null,null,false);
  312.          this.bmpShoulder.copyPixels(_loc11_,_loc7_,_loc8_,null,null,true);
  313.          _loc6_ = _loc6_ + 1;
  314.          if(_loc6_ == this.aRoad.length)
  315.          {
  316.             _loc6_ = 0;
  317.          }
  318.          _loc2_ = _loc2_ + 1;
  319.       }
  320.       this.puddle.draw();
  321.    }
  322.    function setRoadBmp(sBmpToRemove)
  323.    {
  324.       this.aRoadNames[sBmpToRemove].dispose();
  325.       delete this.aRoadNames[sBmpToRemove];
  326.       this.aRoadShoulderNames[sBmpToRemove].dispose();
  327.       delete this.aRoadShoulderNames[sBmpToRemove];
  328.       this.aRoadBmp = new Array();
  329.       this.aRoadShoulderBmp = new Array();
  330.       var _loc3_ = this.roadInd;
  331.       var _loc7_ = - this.distance;
  332.       var _loc4_ = undefined;
  333.       var _loc2_ = undefined;
  334.       var _loc5_ = 0;
  335.       do
  336.       {
  337.          _loc4_ = this.aRoad[_loc3_];
  338.          if(_loc4_.b2Lanes && (this.aRoad[_loc3_ + 1].ind == 10 || this.aRoad[_loc3_ + 1].ind == 9))
  339.          {
  340.             var _loc6_ = 10 - this.lane;
  341.             this.aRoad[_loc3_ + 1] = this.aRoadTiles[_loc6_];
  342.          }
  343.          _loc2_ = _loc4_.sName;
  344.          if(this.aRoadNames[_loc2_] == undefined)
  345.          {
  346.             this.aRoadNames[_loc2_] = flash.display.BitmapData.loadBitmap(_loc2_);
  347.             this.aRoadShoulderNames[_loc2_] = flash.display.BitmapData.loadBitmap(_loc2_ + " shoulder");
  348.          }
  349.          this.aRoadBmp[_loc5_] = this.aRoadNames[_loc2_];
  350.          this.aRoadShoulderBmp[_loc5_] = this.aRoadShoulderNames[_loc2_];
  351.          _loc7_ += _loc4_.height;
  352.          _loc5_ = _loc5_ + 1;
  353.          _loc3_ = _loc3_ + 1;
  354.          if(_loc3_ == this.aRoad.length)
  355.          {
  356.             _loc3_ = 0;
  357.          }
  358.       }
  359.       while(_loc7_ < Game.screenH);
  360.       
  361.    }
  362.    function removeRandomCar(refCar)
  363.    {
  364.       var _loc4_ = this.aRandomCars.length;
  365.       var _loc2_ = 0;
  366.       while(_loc2_ < _loc4_)
  367.       {
  368.          if(this.aRandomCars[_loc2_] == refCar)
  369.          {
  370.             this.aRandomCars.splice(_loc2_,1);
  371.             refCar.remove();
  372.             break;
  373.          }
  374.          _loc2_ = _loc2_ + 1;
  375.       }
  376.    }
  377.    function addRandomCar(posX)
  378.    {
  379.       var _loc7_ = this.aRandomCarsDef.length;
  380.       var _loc10_ = Math.floor(_loc7_ * Math.random());
  381.       var _loc3_ = this.aRandomCarsDef[_loc10_];
  382.       var _loc12_ = _loc3_.maxVel - _loc3_.minVel;
  383.       var _loc5_ = this.player.vel.y + 4 * (1 - 2 * Math.random());
  384.       if(_loc5_ < _loc3_.minVel)
  385.       {
  386.          _loc5_ = _loc3_.minVel;
  387.       }
  388.       else if(_loc5_ > _loc3_.maxVel)
  389.       {
  390.          _loc5_ = _loc3_.maxVel;
  391.       }
  392.       var _loc6_ = new flash.geom.Point(0,_loc5_);
  393.       var _loc2_ = new flash.geom.Point();
  394.       var _loc4_ = undefined;
  395.       if(this.player.vel.y < _loc6_.y)
  396.       {
  397.          _loc2_.y = -50;
  398.          _loc4_ = Game.screenH - 1;
  399.       }
  400.       else
  401.       {
  402.          _loc2_.y = Game.screenH + 50;
  403.          _loc4_ = 1;
  404.       }
  405.       if(posX == undefined)
  406.       {
  407.          do
  408.          {
  409.             _loc2_.x = 30 + 440 * Math.random();
  410.          }
  411.          while(this.bmpShoulder.hitTest(new flash.geom.Point(0,0),250,new flash.geom.Point(_loc2_.x,_loc4_)));
  412.          
  413.       }
  414.       else
  415.       {
  416.          _loc2_.x = posX;
  417.       }
  418.       var _loc8_ = !this.player.bEnter ? 0 : 150;
  419.       var _loc9_ = new Car(_loc3_.sLinkageId,_loc2_,_loc6_,this.mcCanvas,Game.carDepth,_loc8_);
  420.       this.aRandomCars.push(_loc9_);
  421.       Game.carDepth += 3;
  422.       if(Game.carDepth > 190)
  423.       {
  424.          Game.carDepth = 100;
  425.       }
  426.    }
  427.    function addPuddle(posNew)
  428.    {
  429.       var _loc4_ = Math.round(Math.random());
  430.       var _loc2_ = undefined;
  431.       if(posNew != undefined)
  432.       {
  433.          _loc2_ = posNew.clone();
  434.       }
  435.       else
  436.       {
  437.          _loc2_ = new flash.geom.Point(0,1);
  438.          do
  439.          {
  440.             _loc2_.x = 50 + Math.round(450 * Math.random());
  441.             var _loc3_ = new flash.geom.Point(0,0);
  442.             var hit0 = this.bmpShoulder.hitTest(_loc3_,250,_loc2_);
  443.             _loc2_.x += 34;
  444.             var hit1 = this.bmpShoulder.hitTest(_loc3_,250,_loc2_);
  445.             _loc2_.x += 34;
  446.             var hit2 = this.bmpShoulder.hitTest(_loc3_,250,_loc2_);
  447.          }
  448.          while(hit0 || hit1 || hit2);
  449.          
  450.          _loc2_.y = Game.screenH;
  451.       }
  452.       this.puddle = new Puddle(_loc2_,_loc4_,this.mcCanvas);
  453.    }
  454.    function removePuddle(Void)
  455.    {
  456.       this.puddle.remove();
  457.       this.addPuddle();
  458.    }
  459.    function loseLife(Void)
  460.    {
  461.       this.lives = this.lives - 1;
  462.       this.setLivesMeter();
  463.       this.setEnergyMeter(100);
  464.       if(this.lives <= 0)
  465.       {
  466.          this.gameOver(false);
  467.       }
  468.       else
  469.       {
  470.          this.player.newLife();
  471.       }
  472.    }
  473.    function gameOver(bWin)
  474.    {
  475.       this.stopWork();
  476.       if(!bWin)
  477.       {
  478.          this.mcContinue.gotoAndPlay("show");
  479.          this.mcContinue.value = 10;
  480.          this.onEnterFrame = this.checkContinue;
  481.       }
  482.       else
  483.       {
  484.          this.mcSummary.bWin = bWin;
  485.          this.mcSummary.gotoAndPlay(1);
  486.       }
  487.    }
  488.    function onEnemyDead(Void)
  489.    {
  490.       this.enemy.remove;
  491.       delete this.enemy;
  492.       this.player.bExit = true;
  493.       this.player.hideWeapon();
  494.    }
  495.    function onPlayerOut(Void)
  496.    {
  497.       Game.level = Game.level + 1;
  498.       this.stopWork();
  499.       if(Game.level >= this.aEnemiesDef.length)
  500.       {
  501.          this.gameOver(true);
  502.       }
  503.       else
  504.       {
  505.          this.removeRoad();
  506.          this.showMissionInfo();
  507.       }
  508.    }
  509.    function createShot(Void)
  510.    {
  511.       var _loc2_ = Game.bulletDepth;
  512.       this.mcShot = this.mcCanvas.attachMovie(this.sEnemy + " shot","mcShot" + _loc2_,_loc2_);
  513.       this.mcShot.pos.x = this.player.pos.x;
  514.       this.mcShot.pos.y = this.player.pos.y + this.player.height / 2;
  515.       this.mcShot.vel.x = 0;
  516.       this.mcShot.vel.y = 15;
  517.       this.mcShot.type = 0;
  518.       Game.bulletDepth = Game.bulletDepth + 1;
  519.       if(Game.bulletDepth > 290)
  520.       {
  521.          Game.bulletDepth = 200;
  522.       }
  523.       return this.mcShot;
  524.    }
  525.    function removeShot(Void)
  526.    {
  527.       this.mcShot.removeMovieClip();
  528.    }
  529.    function createObstacle(Void)
  530.    {
  531.       this.mcObstacle = this.mcCanvas.attachMovie(this.sEnemy + " obstacle","mcObstacle",6);
  532.       this.mcObstacle.pos.x = this.enemy.pos.x;
  533.       this.mcObstacle.pos.y = this.enemy.pos.y;
  534.       this.mcObstacle.vel.x = 0;
  535.       this.mcObstacle.vel.y = -8;
  536.       this.mcObstacle.type = 1;
  537.    }
  538.    function removeObstacle(Void)
  539.    {
  540.       this.mcObstacle.removeMovieClip();
  541.    }
  542.    function setEnergyMeter(energy)
  543.    {
  544.       this.mcEnergy.gotoAndStop(1 + energy / 10);
  545.    }
  546.    function setLivesMeter(Void)
  547.    {
  548.       this.mcLives.gotoAndStop(1 + this.lives);
  549.    }
  550.    function setLevelMeter(Void)
  551.    {
  552.       this.mcLevel.tfLevel.text = Game.level + 1;
  553.    }
  554.    function setPointsMeter(Void)
  555.    {
  556.       var _loc3_ = 5;
  557.       var _loc2_ = this.points.toString().length;
  558.       var _loc4_ = "00000";
  559.       this.mcPoints.tfPoints.text = _loc4_.substr(0,_loc3_ - _loc2_) + this.points;
  560.    }
  561.    function removeRoad(Void)
  562.    {
  563.       this.enemy.remove();
  564.       this.bmpRoad.dispose();
  565.       this.bmpShoulder.dispose();
  566.       this.player.remove();
  567.       while(this.aRandomCars.length > 0)
  568.       {
  569.          this.removeRandomCar(this.aRandomCars[0]);
  570.       }
  571.       this.removeObstacle(this.mcObstacle);
  572.       this.removeShot(this.mcShot);
  573.    }
  574.    function showMissionInfo(Void)
  575.    {
  576.       this.sEnemy = this.aEnemiesDef[Game.level];
  577.       this.mcMissionInfo.attachMovie("mission info","mcInfo",0);
  578.       this.btnPause.enabled = false;
  579.    }
  580.    function loop(Void)
  581.    {
  582.       this.step();
  583.       this.draw();
  584.    }
  585.    function protectPlayer(Void)
  586.    {
  587.       this.player.setShieldOn();
  588.    }
  589.    function onReleasePause(Void)
  590.    {
  591.       if(this.onEnterFrame == null || this.onEnterFrame == undefined)
  592.       {
  593.          this.startWork();
  594.       }
  595.       else
  596.       {
  597.          this.stopWork();
  598.       }
  599.    }
  600.    function addPoints(value)
  601.    {
  602.       this.points += value;
  603.       if(this.points < 0)
  604.       {
  605.          this.points = 0;
  606.       }
  607.       this.setPointsMeter();
  608.    }
  609.    function showBonus(Void)
  610.    {
  611.       this.mcBonus.play();
  612.    }
  613.    function showPoints(pos, value)
  614.    {
  615.       var _loc3_ = this.mcCanvas.getNextHighestDepth();
  616.       var _loc2_ = this.mcCanvas.attachMovie("points anim","points" + _loc3_,_loc3_);
  617.       _loc2_._x = pos.x;
  618.       _loc2_._y = Game.screenH - pos.y;
  619.       _loc2_.points = value <= 0 ? value : "+" + value;
  620.    }
  621.    function checkContinue(Void)
  622.    {
  623.       if(this.mcContinue._currentframe == this.mcContinue._totalframes)
  624.       {
  625.          this.onEnterFrame = this.countDown;
  626.          this.counter = 10;
  627.          this.startTime = getTimer() + 1000;
  628.          this.mcContinue.btnYes.onRelease = mx.utils.Delegate.create(this,this.onReleaseYes);
  629.          this.mcContinue.btnNo.onRelease = mx.utils.Delegate.create(this,this.onReleaseNo);
  630.          this.oKeyList = new Object();
  631.          this.oKeyList.onKeyDown = mx.utils.Delegate.create(this,this.onSpaceCont);
  632.          Key.addListener(this.oKeyList);
  633.       }
  634.    }
  635.    function countDown(Void)
  636.    {
  637.       this.mcContinue.value = this.counter;
  638.       if(getTimer() - this.startTime > 1000)
  639.       {
  640.          this.startTime = getTimer();
  641.          this.counter = this.counter - 1;
  642.          if(this.counter < 0)
  643.          {
  644.             this.onEnterFrame = null;
  645.             this.onReleaseNo();
  646.          }
  647.       }
  648.    }
  649.    function onReleaseYes(Void)
  650.    {
  651.       Key.removeListener(this.oKeyList);
  652.       this.onEnterFrame = null;
  653.       this.mcContinue.gotoAndStop("hide");
  654.       this.points = 0;
  655.       this.setPointsMeter();
  656.       this.lives = 4;
  657.       this.setLivesMeter();
  658.       this.player.newLife();
  659.       this.startWork();
  660.    }
  661.    function onReleaseNo(Void)
  662.    {
  663.       Key.removeListener(this.oKeyList);
  664.       this.onEnterFrame = null;
  665.       this.mcContinue.gotoAndStop("hide");
  666.       this.mcSummary.bWin = false;
  667.       this.mcSummary.gotoAndPlay(1);
  668.    }
  669.    function onSpaceCont(Void)
  670.    {
  671.       if(Key.isDown(32))
  672.       {
  673.          this.onReleaseYes();
  674.       }
  675.    }
  676.    function setLives(Void)
  677.    {
  678.       this.lives = !Application.bEasy ? 3 : 4;
  679.       this.setLivesMeter();
  680.    }
  681. }
  682.